{extend name="pub/base2" /}
{block name="title"}
<title>用户编辑</title>
{/block}

{block name="body"}
<article class="clearfix pd-20">
    <form class="form form-horizontal">
        <input type="hidden" value="{$user.id}" name="id">
        <div class="row clearfix">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$user.username}" readonly>
            </div>
        </div>

        <div class="row clearfix">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>新密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" name="password">
            </div>
        </div>

        <div class="row clearfix">
            <label class="form-label col-xs-4 col-sm-3">vip到期时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" name="expire_time" class="input-text" value="{$expire_time}">
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
<script>
    $(function(){
        $("form").validate({
            rules:{
                username: {
                    required: true,
                    rangelength: [6, 20]
                },
                password: {
                    rangelength: [6, 16]
                }
            },
            messages: {
                username: {
                    required: "用户名不能为空",
                    rangelength: "用户名长度6-20个字符"
                },
                password: {
                    rangelength: "密码长度6-16个字符"
                }
            },
            onkeyup:false,
            focusCleanup:false,
            submitHandler: function(form) {
                $.ajax({
                    url:"{:url('edit')}",
                    type:'post',
                    data:$('form').serialize(),
                    success(res) {
                        subResHandle(res)
                    }
                })
            }
        });
    });
</script>
{/block}